home *** CD-ROM | disk | FTP | other *** search
- /******************************************************/
- /* */
- /* CBrowserPane.c */
- /* */
- /* Written in Think C version 4.0.2 */
- /* Based on CStarterPane.c */
- /* */
- /* Allen Stenger January 1991 */
- /* */
- /******************************************************/
-
- #include "CBrowserPane.h"
-
- #define FONTNUMBER 4 /* Monaco */
- #define FONTSIZE 9
-
- void CBrowserPane::IBrowserPane(CView *anEnclosure,
- CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing,
- SizingOption aVSizing,
- /* added parameters */
- char **theDataH,
- short theLineCt,
- long **theLineStartsH)
- {
- FontInfo theFontInfo; /* from GetFontInfo */
- Rect panoRect; /* panorama rectangle */
- short thisLineLength, /* length of current and */
- maxLineLength; /* longest line in */
- /* **itsDataH */
- long i; /* loop control */
-
- itsDataH = theDataH;
- itsLineCt = theLineCt;
- itsLineStartsH = theLineStartsH;
-
- CPanorama::IPanorama(anEnclosure, aSupervisor,
- aWidth, aHeight,
- aHEncl, aVEncl, aHSizing, aVSizing);
- Prepare();
- TextFont(FONTNUMBER);
- TextSize(FONTSIZE);
- GetFontInfo( &theFontInfo );
- itsLineHeight = theFontInfo.ascent +
- theFontInfo.descent +
- theFontInfo.leading;
-
- /* get maximum line length - needed for horizontal */
- /* scrolling control */
- maxLineLength = 1;
- for (i=0; i<itsLineCt; i++) {
- thisLineLength = (*theLineStartsH)[i+1] -
- (*theLineStartsH)[i];
- if (thisLineLength > maxLineLength)
- maxLineLength = thisLineLength;
- }
-
- /* set up extents of scrolling controls (panorama) */
- SetRect(&panoRect,0,0,maxLineLength,itsLineCt);
- SetScales(theFontInfo.widMax,itsLineHeight);
- SetBounds(&panoRect);
- }
-
- void CBrowserPane::Draw(Rect *area)
- {
- short firstLine,lastLine;
- short i; /* loop control */
-
- /* Get first and last line numbers to draw. */
- /* We will draw an extra line at the top so that */
- /* if we scroll upward the descenders will be */
- /* available for scrolling. */
- firstLine = (*area).top / itsLineHeight;
- if (firstLine < 1) firstLine = 1;
- lastLine = 1 + (*area).bottom / itsLineHeight;
- if (lastLine > itsLineCt) lastLine = itsLineCt;
-
- for (i=firstLine; i<=lastLine; i++) {
- MoveTo(0,i*itsLineHeight);
- DrawText(*itsDataH+(*itsLineStartsH)[i-1],0,
- (*itsLineStartsH)[i]-
- (*itsLineStartsH)[i-1]);
- /* note that we do not expand tabs - this could */
- /* be added if desired */
- }
- }
-